package com.crm.controller;

import com.crm.entity.Permission;
import com.crm.repository.PermissionRepository;
import com.crm.service.impl.PermissionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 赵祺
 * @date 2020/5/28 16:42
 */
@RestController
@RequestMapping("permission")
public class PermissionController {
    @Autowired
    private PermissionRepository permissionRepository;
    @Autowired
    private PermissionServiceImpl service;
   @GetMapping
    public List<Permission> getPermission(String userId){
        List<Permission> perMission = permissionRepository.getPerMission(userId);
        System.out.println("permission"+perMission);
        return perMission;
    }


     @GetMapping("permissions")
    public Object getAllPeimission(Integer id) {
        System.out.println("id:"+id);
        return service.getPermissionByRoleId(id);
    }
    @PutMapping
    public Object manageRole_Permission(Integer rid,String pids) {
        return service.manageRole_Permission(rid, pids);
    }

}
